package cc.taofoo.JUCTest;

/**
 * suspend
 * resume()顺序提前导致 t2 一直处于 suspend
 */


public class BadSuspend {
    static Object u = new Object();
    static ChangeObjectThread t1 = new ChangeObjectThread();
    static ChangeObjectThread t2 = new ChangeObjectThread();

    public static class ChangeObjectThread extends Thread {
        @Override
        public void run() {
            synchronized (u){
                System.out.println(getName());
                Thread.currentThread().suspend();
            }
        }
    }

    public static void main(String[] args) throws InterruptedException {
        t1.start();
        Thread.sleep(100);
        t2.start();
        t1.resume();
//        Thread.sleep(100);
        t2.resume();
        t1.join();
        t2.join();
    }
}
